@import "src/assets/css/variables";

.streamlit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: normal;
  padding: 0.375rem 0.75rem;
  border-radius: 0.25rem;
  margin: 0;
  line-height: 1.6;
  color: $black;

  &.button-fluid-width {
    width: 100%;
  }

  &.xsmall-button {
    padding: 0.125rem 0.5rem;
    font-size: $font-size-sm;
  }

  &.small-button {
    padding: 0.25rem 0.75rem;
  }

  &.medium-button {
    padding: 0.375rem 0.75rem;
  }

  &.large-button {
    padding: 0.75rem 0.75rem;
  }

  &:focus {
    box-shadow: 0 0 0 0.2rem $primary-a50;
    outline: none;
  }

  &.primary-button {
    background-color: $white;
    border: 1px solid $gray-lighter;

    &:hover {
      border-color: $primary;
      color: $primary;
    }

    &:active {
      color: $white;
      border-color: $primary;
      background-color: $primary;
    }

    &:focus:not(:active) {
      border-color: $primary;
      color: $primary;
    }

    &:disabled,
    &:disabled:hover,
    &:disabled:active {
      background-color: $gray-lighter;
      border-color: transparent;
      color: $gray;
    }
  }

  &.secondary-button {
    background-color: transparent;
    border: 1px solid transparent;

    &:hover {
      border-color: transparent;
      color: $primary;
    }

    &:active {
      color: $primary;
      border-color: transparent;
      background-color: transparent;
    }

    &:focus:not(:active) {
      color: $primary;
      border-color: transparent;
    }

    &:disabled,
    &:disabled:hover,
    &:disabled:active {
      background-color: $gray-lighter;
      border-color: transparent;
      color: $gray;
    }
  }

  &.link-button {
    background-color: transparent;
    padding: 0;
    border: none;
    color: $primary;

    &:hover {
      text-decoration: underline;
    }

    &:active {
      text-decoration: underline;
      background-color: transparent;
      color: $primary;
    }

    &:disabled,
    &:disabled:hover,
    &:disabled:active {
      background-color: $gray-lighter;
      border-color: transparent;
      color: $gray;
    }
  }

  &.minimal-button {
    background-color: transparent;
    border: none;
    box-shadow: none;
    padding: 0;

    &:hover,
    &:active,
    &:focus {
      color: $primary;
    }
  }

  &.icon-button {
    background-color: transparent;
    border: none;
    border: 1px solid transparent;

    &.small-button {
      padding: 0.25rem;
    }

    &.medium-button {
      padding: 0.75rem;
    }

    &.large-button {
      padding: 1rem;
    }

    &:hover {
      border-color: $primary;
      color: $primary;

      /* I don't like this, but this is a result of the icon being on a side bar */
      .open-iconic {
        opacity: 1;
      }
    }

    &:active {
      color: $white;
      border-color: $primary;
      background-color: $primary;

      .open-iconic {
        opacity: 1;
      }
    }

    &:focus {
      .open-iconic {
        opacity: 1;
      }
    }

    &:focus:not(:active) {
      color: $primary;
      border-color: $primary;
    }

    &:disabled,
    &:disabled:hover,
    &:disabled:active {
      background-color: $gray-lighter;
      border-color: transparent;
      color: $gray;
    }
  }
}
